package com.mf.security.db;

import com.mf.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * @Author: lmf
 * @Create: 2024/8/6 15:05
 * Description:
 */


@Component
public class DBUserDetailsManager implements UserDetailsService {
    @Resource
    private IUserService userService;

    /**
     * 从数据库获取用户信息
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return userService.loadUserByUsername(username);
    }
}
